import { request } from '../utils/request'

export interface ServiceItem {
    code: string
    name: string
}

export interface GoodsItem {
    imgUrl: string
    itemId: number
    maxPrice: number
    minPrice: number
    salesCnt90d: number | null
    sellPointInfo: string | null
    serviceList: ServiceItem[]
    title: string
    skuCnt: number
}

export interface GoodsListResponse {
    msg: string
    code: number
    result: {
        body: {
            data: GoodsItem[]
            totalCount: number
            code: number
            msg: string
        }
    }
}

export interface GoodsListParams {
    userId: string
    tagName: string
    keyword: string
    pageNum: number
    pageSize: number
}

export async function getGoodsList(params: GoodsListParams): Promise<GoodsListResponse> {
    return request<GoodsListResponse>('https://alfx.jiayia.com/api/product/getProductList', {
        method: 'GET',
        params: {
            userId: params.userId,
            tagName: params.tagName,
            keyword: params.keyword,
            pageNum: params.pageNum,
            pageSize: params.pageSize
        }
    })
}
